---
import Benchmark from "./Benchmark.astro";
import BenchmarkLine from "./BenchmarkLine.astro";
import reverseProxyThroughput from "../../assets/benchmarks/reverseProxyThroughput";
import reverseProxyLatency from "../../assets/benchmarks/reverseProxyLatency";
---

<section id="benchmarks" class="py-20">
  <div class="container">
    <div class="text-center mb-16">
      <h2 class="text-3xl md:text-4xl font-bold mb-4">Fast performance</h2>
      <p class="text-muted-foreground text-lg max-w-2xl mx-auto">
        Ferron can outperform other popular web servers in performance benchmark
        tests across different workloads.
      </p>
    </div>
    <div class="grid grid-cols-1 lg:grid-cols-2 gap-8">
      <Benchmark
        title="Static file serving"
        description="Requests per second when serving static files (higher is better)"
        data={[
          {
            name: "1KB file",
            ferron: 124552.78,
            competitor1: 93459.1,
            competitor2: 25384.9,
            competitor3: 100983.17
          },
          {
            name: "100KB file",
            ferron: 26228.44,
            competitor1: 11720.13,
            competitor2: 17797.22,
            competitor3: 29259.29
          },
          {
            name: "1MB file",
            ferron: 2537.57,
            competitor1: 1278.84,
            competitor2: 4618.48,
            competitor3: 3306.1
          }
        ]}
        unit={"req/s"}
        higherIsBetter={true}
        competitor1={"lighttpd"}
        competitor2={"Apache httpd"}
        competitor3={"Caddy"}
        command="ferrbench -c 1000 -d 60s -t 12 -h https://localhost --http2"
        date={new Date("2025-09-19")}
        system={"AMD Ryzen 5 8600G, 32GB RAM"}
      />
      <BenchmarkLine
        title="Reverse proxy performance"
        description={'Requests per second when proxying to a "Hello World" Axum application (higher is better)'}
        data={reverseProxyThroughput}
        unit={"req/s"}
        higherIsBetter={true}
        competitor1={"Traefik"}
        competitor2={"NGINX mainline"}
        competitor3={"Caddy"}
        command="ferrbench -c $CONCURRENCY -d 5s -t 16 -h https://localhost --http2"
        date={new Date("2025-10-26")}
        system={"AMD Ryzen 7 8700G, 32GB RAM"}
      />
      <BenchmarkLine
        title="Latency under load (reverse proxy)"
        description={'Average response time under high concurrency proxying to a "Hello World" Axum application (lower is better)'}
        data={reverseProxyLatency}
        unit={"ms"}
        higherIsBetter={false}
        competitor1={"Traefik"}
        competitor2={"NGINX mainline"}
        competitor3={"Caddy"}
        command="ferrbench -c $CONCURRENCY -d 5s -t 16 -h https://localhost --http2"
        date={new Date("2025-10-26")}
        system={"AMD Ryzen 7 8700G, 32GB RAM"}
      />
      <Benchmark
        title="PHP performance"
        description="Requests per second when serving PHP through PHP-FPM (higher is better)"
        data={[
          {
            name: "Hello World PHP script",
            ferron: 44364.78,
            competitor1: 45255.49,
            competitor2: 43767.75,
            competitor3: 34664.32
          },
          {
            name: "Fresh WordPress",
            ferron: 223.91,
            competitor1: 225.86,
            competitor2: 222.74,
            competitor3: 223.08
          }
        ]}
        unit={"req/s"}
        higherIsBetter={true}
        competitor1={"lighttpd"}
        competitor2={"Apache httpd"}
        competitor3={"Caddy"}
        command="ferrbench -c 100 -d 60s -t 12 -h https://localhost --http2"
        date={new Date("2025-06-13")}
        system={"AMD Ryzen 5 8600G, 32GB RAM"}
      />
    </div>
  </div>
</section>
